package com.zzyk.microCloud.controller;

import com.zzyk.main.configuration.exception.UserException;
import com.zzyk.main.controller.BaseController;
import com.zzyk.main.service.DeviceOriginDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author wss_PC
 * @DESCRIPTION 历史数据
 * @create 2020-7-8
 */
@RestController
@CrossOrigin(allowCredentials = "true")
@RequestMapping("/historyData")
public class HistoryDataController extends BaseController {
    @Autowired
    private DeviceOriginDataService dataService;

    /**
     * 获取历史数据
     *
     * @param dId
     * @param param
     * @return
     */
    @GetMapping("/getHistoryDataByParam")
    public Map<String, Object> getHistoryDataByParam(Integer dId, String param, String beginDate, String endDate, Integer type) throws UserException {
        Map map = new HashMap(2);
        map.put("data", dataService.findDeviceOriginData(currentUser().getEnterprise(), dId, param, beginDate, endDate, type));
        map.put("param", param);
        return map;
    }
}